package com.smart.controller.app;

import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.util.ArrayList;
import com.smart.vo.app.CarVo;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import com.smart.service.CarService;
import com.smart.common.util.Messages;
import com.smart.service.SsSiteService;
import io.swagger.annotations.ApiOperation;
import com.smart.controller.BaseController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lgb
 * @date 2020年6月16日 下午4:49:03
 * Copyright (C) 深圳工勘科技
 * @说明: app端车辆管理
 **/
@RestController
@RequestMapping("/app/equipment")
@Api(value="appcar",tags="智慧工地-设备管理")
public class AppEquipmentController extends BaseController{
	
	@Resource
	private CarService carService;
	@Resource
	private SsSiteService siteService;
	
	@ApiOperation(value="查询gps列表",notes="查询gps列表")
    @GetMapping("/gpslist")
	public Messages<List<CarVo>> gpsList(String name,
			@RequestParam(name="pageNum")Integer pageNum,
			@RequestParam(name="pageSize")Integer pageSize){
		List<CarVo> voList=carService.findCarVoList(name,pageNum,pageSize);
		return Messages.success(voList);
	}
	@ApiOperation(value="查询工地列表",notes="查询工地列表")
    @GetMapping("/sitelist")
	public Messages<List<Object>> siteList(
			@RequestParam(name="pageNum")Integer pageNum,
			@RequestParam(name="pageSize")Integer pageSize){
		List<Object> list = new ArrayList<>();
		if(pageNum == 1){
			Map<String,Object> map = new HashMap<>();
			map.put("siteId", 8);
			map.put("siteName","罗湖豪园金钻");
			map.put("online",1);
			map.put("offline",0);
			String[] type={"旋挖机","成槽机"};
			map.put("carType",type);
			list.add(map);
		}
		return Messages.success(list);
	}
	@ApiOperation(value="查询工地设备",notes="查询工地设备")
    @GetMapping("/detail")
	public Messages<Object> detail(String name){
		List<CarVo> voList=carService.findCarVoList(name,1,100);
		return Messages.success(voList);
	}
	
	@ApiOperation(value="查询设备历史",notes="查询设备历史")
    @GetMapping("/history")
	public Messages<List<Map<String,Object>>> history(
		String carNo){
		List<Map<String,Object>> history = new ArrayList<>();
		Map<String,Object> data = new HashMap<>();
		data.put("carNo","BG369");
		data.put("name","陈风");
		data.put("workDate", "2020-05-20 12:34:12");
		history.add(data);
		Map<String,Object> data1 = new HashMap<>();
		data.put("carNo","BG369");
		data1.put("name", "陈风");
		data1.put("workDate", "2020-06-20 02:34:52");
		history.add(data1);
		return Messages.success(history);
	}
}